import {Component, Input} from '@angular/core';
import {EditorService} from "../../services/EditorService";

@Component({
  templateUrl: 'emoji-editor.html'
})
export class EmojiEditor {
  @Input()
  emojiInputName: string = '';

  constructor(private editorService: EditorService) {
    if (this.emojiInputName !== '')
    {
      editorService.getSource(this.emojiInputName).subscribe(emojiId => this.insertEmoji(emojiId));
    }
  }

  @Input()
  currentText: string = '';

  insertEmoji(emojiId: string)
  {
    this.currentText += `[emoji-${emojiId}]`;
  }
}
